function a=EKF_weight(S,Fnk,Outputs,a_pre,v_o,w_o,aph,b,a_d)
    %初始设置
%     aph=0.3;
%     b=0.2;
%     a_d=ones(size(a_pre));
    % 初始化静态变量
    persistent P0;
    if isempty(P0)
            P0=1*eye(size(a_pre,2));
    end
    %生成雅可比矩阵
    numOutputs=2;
    numRules=16;
    dv=[];
    dw=[];
    for i=1:numOutputs
        for j=1:numRules
            dvi=(Fnk(j)*sum(S(:)))/(2*power(1+aph*Outputs(i),2));
            if(i==1)
                dwi=(Fnk(j)*sum(S(:)))/(2*b*power(1+aph*Outputs(i),2));
            else
                dwi=-(Fnk(j)*sum(S(:)))/(2*b*power(1+aph*Outputs(i),2));
            end
            dv=[dv,dvi];
            dw=[dw,dwi];
        end
    end
    O_k=[dv;dw];
    % 观测噪声协方差矩阵 R
    R = 0.01;
    % 过程噪声协方差矩阵 Q
    Q = 0.01 * eye(size(a_pre,2));
    % 卡尔曼增益 K
    K = P0*O_k'/(R+O_k*P0*O_k');
    %
    xi_k = randn(1, 2) * sqrt(R);
    o=[v_o,w_o]+(a_pre-a_d)*O_k'+xi_k;
    od=[v_o,w_o]+xi_k;
    e=o-od;
    a_update=a_pre-(K*e')';
    P=(eye(size(a_pre,2))-K*O_k)*P0+Q;
    %
    a=a_update;
    P0=P;
end